package com.ktjy.springthymeleaf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.ktjy.springthymeleaf.entity.Right;
import com.ktjy.springthymeleaf.mapper.RightMapper;
import com.ktjy.springthymeleaf.service.RightService;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;

/**
 * @return 13141
 * 2025/7/14
 * 19:27
 */
@Service("rightService")
public class RightServiceImpl implements RightService {
    private static final Logger LOGGER = LoggerFactory.getLogger(RightServiceImpl.class);
    @Resource
    private RightMapper rightMapper;
    @Override
    public int insert(Right right) {
        return rightMapper.insert(right);
    }

    @Override
    public int delete(String id) {
        QueryWrapper<Right> wrapper = new QueryWrapper<Right>();
        wrapper.eq("right_code", id);
        return rightMapper.delete(wrapper);
    }

    @Override
    public int update(Right right) {
        return rightMapper.updateById(right);
    }

    @Override
    public Right get(String id) {
        return rightMapper.selectById(id);
    }

    @Override
    public List<Right> findAll() {
        return rightMapper.selectList(null);
    }
}
